package Java9_8;

import java.util.*;

public class SetCompany {
    String name;
    String ip;
    String phone;
    String type;

    public SetCompany(String name, String ip, String phone, String type) {
        this.name = name;
        this.ip = ip;
        this.phone = phone;
        this.type = type;
    }

    Person p = new Person();
    Set set=new HashSet();

    public boolean zhaopin(Person gh) {
        if (set.contains(gh)) {
            return false;
        }
        return set.add(gh);
    }

    public void show() {
       Iterator in=set.iterator();
       while (in.hasNext()){
           Object o=in.next();
           System.out.println(o);
       }
    }

    public boolean citui(String gh) {
        for (Object o:set) {
            if (((Person)o).getGonghao().equals(gh)) {
                set.remove(o);
                return true;
            }
        }
        return false;
    }

    public int shuliang() {
        return set.size();
    }

    public Person maxmoney() {
        if (set.isEmpty()) {
            return null;
        }
       int max=0;
        Person pmax=null;
        for (Object o:set){
            if (((Person) o).getMoney() > max) {
                pmax=(Person)o;
            }
        }
        return pmax;
    }
}
